var states = {

}

var state = ['通畅', '正常',  '拥堵', '无法通行'];

module.exports.update = function(keys){
	for(var i = 0; i< keys.length; ++i){

		if(states[keys[i]] != undefined) continue;
		var s = Math.floor(Math.random()*10);
		var s2 = 0;
		if(s<6){
			s2 = 0
		}
		else if(s >= 6 && s <8){
			s2 = 1;
		} else if(s>=8 && s<9){
			s2 =2;
		} else {
			s2=3
		}

		states[keys[i]] = state[s2];
	}

	console.log(states);
}

module.exports.getRandomState = function(){
	var s = Math.floor(Math.random()*10);
		var s2 = 0;
		if(s<6){
			s2 = 0
		}
		else if(s >= 6 && s <8){
			s2 = 1;
		} else if(s>=8 && s<9){
			s2 =2;
		} else {
			s2=3
		}

		return  state[s2];
	 
}

module.exports.getByRoad = function(id){
	return states[id];
}